package dataStructure.chapter06_树.part1二叉树.binarysearchtree3;

/**
 * @author https://gitee.com/W_Jun
 * @date 2022-04-26 20:48
 * @Description
 */
public class TestBinarySearchTree {
    public static void main(String[] args) {
        Integer data[] = new Integer[] {7, 4, 9, 2, 5, 8, 11,3};
        BinarySearchTree<Integer> bst = new BinarySearchTree<>();
        for (int i = 0; i < data.length; i++) {
            bst.add(data[i]);
        }

        //原来写死的逻辑如打印 在使用的时候具体实现
/*        bst.levelOrder(new BinarySearchTree.Visitor<Integer>() {
            @Override
            public void visit(Integer element) {
                System.out.print("_" + element +" ");
            }
        });*/

        //前序
/*        bst.preorder(new BinarySearchTree.Visitor<Integer>() {
            @Override
            public void visit(Integer element) {
                System.out.print("_" + element +" ");
            }

        });*/

        //中序
/*        bst.inorder(new BinarySearchTree.Visitor<Integer>() {
            @Override
            public void visit(Integer element) {
                System.out.print("_" + element +" ");
            }

        });*/

        //后序
        bst.postorder(new BinarySearchTree.Visitor<Integer>() {
            @Override
            public void visit(Integer element) {
                System.out.print("_" + element +" ");
            }

        });

        //打印测试
        System.out.println();
        System.out.println("================");
        System.out.println(bst);
    }
}
